// A 2d shader that blurs a texture by sampling a number of pixels to the top,bottom,left,right of the original
float screenHeight;
float screenWidth;
float blurPixels;

sampler texSampler : register(s0);
 
float4 PixelShaderFunction(float2 Tex: TEXCOORD0) : COLOR
{
    float4 Color = (float4)0;

	float blurDistanceX = blurPixels / screenWidth;
	float blurDistanceY = blurPixels / screenHeight;
 
    Color += tex2D(texSampler, float2(Tex.x, Tex.y));
    Color += tex2D(texSampler, float2(Tex.x+blurDistanceX, Tex.y+blurDistanceY));
    Color += tex2D(texSampler, float2(Tex.x-blurDistanceX, Tex.y-blurDistanceY));
    Color += tex2D(texSampler, float2(Tex.x+blurDistanceX, Tex.y-blurDistanceY));
    Color += tex2D(texSampler, float2(Tex.x-blurDistanceX, Tex.y+blurDistanceY));
    Color = Color / 5; 
 
    return Color;
}

technique Technique1
{
    pass P0
    {
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}